package com.jsoup.controller;

import com.jsoup.bean.Article;
import com.jsoup.service.ArticleService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    private ArticleService articleService;

    /**
     * 加载首页
     *
     * @param model
     * @return
     */
    @RequestMapping(value = {"", "/", "/index"})
    public String index(Model model) {
        // 加载博文推荐
        List<Article> articleList = articleService.selectArticleByArticleViews();
        model.addAttribute("articleList", articleList);
        return "index";
    }
}
